<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>客户编辑</title>
[#include "/include/jsvalidation.ftl"]
[#include "../../include/main.ftl"]
[#include "/include/popdialog.ftl"]
    <script>
		var currentEditIdx = 0;
        $(function() {
            $("#customerEdit").tabs({selected:${obj.editIndex!0}});
            $("#proxyInfo").tabs();
        });
        function refreshPage() {
            self.location = "/Ins/customer/edit/${obj.CustomerObj.sn?default('')}?editIndex="+currentEditIdx;
        }

		function editLinkMan(sn){
			currentEditIdx = 1;
			if (sn==undefined)
			    popDialog("editLinkMan", "编辑联系人",
                        "/Ins/customer/linkman/new/${obj.CustomerObj.sn?default('')}",
                        refreshPage,400,400);
            else
                popDialog("editLinkMan", "编辑联系人",
                        "/Ins/customer/linkman/edit/"+sn,
                        refreshPage,400,400);
		}
		
		function editCar(sn){
			currentEditIdx = 2;
			if (sn==undefined)
			    popDialog("editCar", "编辑车辆",
                        "/Ins/customer/car/new/${obj.CustomerObj.sn?default('')}",
                        refreshPage,500,500);
            else
                popDialog("editCar", "编辑车辆",
                        "/Ins/customer/car/edit/"+sn,
                        refreshPage,500,500);
		}
		
		function editDriver(sn){
			currentEditIdx = 3;
			if (sn==undefined)
			    popDialog("editCar", "编辑驾驶员",
                        "/Ins/customer/driver/new/${obj.CustomerObj.sn?default('')}",
                        refreshPage,400,400);
            else
                popDialog("editCar", "编辑驾驶员",
                        "/Ins/customer/driver/edit/"+sn,
                        refreshPage,400,400);
		}



    </script>
</head>
<body>
<div class="ui-widget page">
[#include '../../top.ftl']

    <div class="content">
    [#include '../../leftNav.ftl']
        <div style="width:845px;height:600px;float: left;padding-left: 5px">
            <div class="ui-widget-content ui-corner-all" style="min-height: 600px;">
                <form action="/Ins/customer/save" method="post" name="mainForm" id="mainForm" >
                <INPUT TYPE="hidden" NAME="sn" VALUE="${obj.CustomerObj.sn?default('')}">
                 <INPUT TYPE="hidden" NAME="createUser" VALUE="${obj.CustomerObj.createUser?default('')}">
                  <INPUT TYPE="hidden" NAME="createTime" VALUE="${(obj.CustomerObj.createTime?string('yyyy-MM-dd'))?default('')}">
                    <input type="button" value="返回列表" onClick="self.location='/Ins/customer/list'">
                    <div id="customerEdit" style="width:830px">
						[#if obj.msg?default('') != '']<script>alert('客户无法删除:找到${obj.msg}');</script>[/#if]
                        <ul style="border-bottom:#aed0ea 1px solid;">
                            <li><a href="#customer_base">基本资料</a></li>
                            <li><a href="#customer_linkman">联系人</a></li>
                            <li><a href="#customer_car">车辆</a></li>
                            <li><a href="#customer_driver">驾驶员</a></li>
                        </ul>
                        <div id="customer_base">

                            <p>
                            	<select name="custType" id="custType">
                                  <option value="0">个人客户</option>
                                  <option value="1">团体客户</option>
                              </select>
 
                                <script>$("#custType").val("${(obj.CustomerObj.custType)?default('')}");</script>
                                </p>

                            <p>客户名称
                                <input type="text"  size="20" id="name" name="name" class="required max-length-100 ">
                                <script>$("#name").val("${(obj.CustomerObj.name)?default('')}");</script>
                                性别
                                <select name="sex" id="sex">
                                  <option value="男">男</option>
                                  <option value="女">女</option>
                              </select>
                              <script>$("#sex").val("${(obj.CustomerObj.sex)?default('')}");</script>
                            </p>
<!--
                            <p>客户简称
                                <input type="text" name="textfield2" id="textfield2">
                            </p>
                            -->

                            <p>身份证号
                                <input type="text"  size="20" id="IDCard" name="IDCard" class="max-length-40 ">
                                <script>$("#IDCard").val("${(obj.CustomerObj.IDCard)?default('')}");</script>
                                <span id="spIDCard"></span> 
                                <script>
                                [#list obj.CustomerIDCardList?default([]) as cid]
									$('#spIDCard').html($('#spIDCard').html()+getFileLink('${cid.sn}'));
                                [/#list]
								</script>
                        【<a href="javaScript:uploadFile('spIDCard','客户','${obj.CustomerObj.sn?default('')}','身份证');">上传</a>】</p>

                            <p>身份证有效期
                                <input type="text"  size="20" id="IDValidDate" name="IDValidDate" class="validate-date-yyyy-MM-dd" onClick="popCalendar(this)" >
                                <script>$("#IDValidDate").val("${(obj.CustomerObj.IDValidDate?string('yyyy-MM-dd'))?default('')}");</script>
                            </p>

                            <p>身份证地址
                                <input type="text"  size="20" id="IDAddress" name="IDAddress" class="max-length-100 ">
                                <script>$("#IDAddress").val("${(obj.CustomerObj.IDAddress)?default('')}");</script>
                            </p>

                            <p>组织机构代码
                                <input type="text"  size="20" id="orgID" name="orgID" class="max-length-40 ">
                                <script>$("#orgID").val("${(obj.CustomerObj.orgID)?default('')}");</script>
                                 <span id="sporgID"></span> 
                                <script>
                                [#list obj.CustomerOrgIDList?default([]) as cid]
									$('#sporgID').html($('#sporgID').html()+getFileLink('${cid.sn}'));
                                [/#list]
								</script>
                        【<a href="javaScript:uploadFile('sporgID','客户','${obj.CustomerObj.sn?default('')}','组织机构代码证');">上传</a>】</p>

                            <p>单位地址
                                <input type="text"  size="20" id="compAddress" name="compAddress" class="max-length-200 ">
                                <script>$("#compAddress").val("${(obj.CustomerObj.compAddress)?default('')}");</script>
                            </p>
                            <p>客户分类
                              <select name="custKind" id="custKind">
                                <option value="准客户" selected>准客户</option>
                                <option value="正式客户">正式客户</option>
                                <option value="VIP客户">VIP客户</option>
                                <option value="无效客户">无效客户</option>
                              </select>
                              <script>$("#custKind").val("${(obj.CustomerObj.custKind)?default('')}");</script>
                              客户分类原因
                              <input type="text"  size="20" id="custKindReason" name="custKindReason" class="max-length-400 ">
                              <script>$("#custKindReason").val("${(obj.CustomerObj.custKindReason)?default('')}");</script>
                            </p>
                            <p>客户来源渠道
                              <select name="custSource" id="custSource">
                                <option value="车行">车行</option>
                                <option value="银行">银行</option>
                                <option value="直销">直销</option>
                                <option value="保险公司">保险公司</option>
                                <option value="代理公司">代理公司</option>
                                <option value="经纪公司">经纪公司</option>
                              </select>
                              <script>$("#custSource").val("${(obj.CustomerObj.custSource)?default('')}");</script>
                            客户来源单位                            
                            <input type="text"  size="20" id="custSourceOrg" name="custSourceOrg" class="max-length-100 ">
                            <script>$("#custSourceOrg").val("${(obj.CustomerObj.custSourceOrg)?default('')}");</script>
                            </p>
                            <p>
                            <input name="submit" type="submit" value="保存" onClick="">
                            | <a href="/Ins/customer/del/${obj.CustomerObj.sn?default('')}" onClick="return confirm('确定删除?')">删除</a></p>
                        </div>
                        <div id="customer_linkman">
                        	<input type="button" value="添加联系人" onClick="editLinkMan();">
                            <table width="100%" border="0" cellspacing="3" cellpadding="3">
                                <tr>
                                    <td bgcolor="#CCCCCC"><strong>姓名</strong></td>
                                    <td bgcolor="#CCCCCC"><strong>与客户关系</strong></td>
                                    <td bgcolor="#CCCCCC"><strong>电话</strong></td>
                                    <td bgcolor="#CCCCCC"><strong>备注</strong></td>
                                    <td bgcolor="#CCCCCC">&nbsp;</td>
                                </tr>
                                [#list obj.CustomerLinkManList?default([]) as CustomerLinkMan]
                                <tr>
                                    <td><a href="javaScript:editLinkMan('${CustomerLinkMan.sn}');">${(CustomerLinkMan.name)?default('空')}</a></td>
                                    <td>${(CustomerLinkMan.relation)?default('')}</td>
                                    <td>${(CustomerLinkMan.tel)?default('')}</td>
                                    <td>${(CustomerLinkMan.memo)?default('')}</td>
                                    <td><input type="checkbox" name="checkbox_${CustomerLinkMan.sn}" id="checkbox_${CustomerLinkMan.sn}">
                                        有效
                                    </td>
                                </tr>
                                [/#list]
                                
                            </table>

                        </div>
                        <div id="customer_car">
                            <input type="button" value="添加车辆" onClick="editCar();">
                            <table width="100%" border="0" cellspacing="3" cellpadding="3">
                                <tr>
                                    <td bgcolor="#CCCCCC"><strong>号牌</strong></td>
                                    <td bgcolor="#CCCCCC"><strong>车辆类型</strong></td>
                                    <td bgcolor="#CCCCCC"><strong>品牌型号</strong></td>
                                    <td bgcolor="#CCCCCC"><strong>使用性质</strong></td>
                                    <td bgcolor="#CCCCCC"><strong>注册日期</strong></td>
                                    <td bgcolor="#CCCCCC"><strong>行车证</strong></td>
                                </tr>
                                [#list obj.CustomerCarList?default([]) as CustomerCar]
                                <tr>
                                    <td><a href="javaScript:editCar('${CustomerCar.sn}');">${(CustomerCar.carNo)?default('空')}</a></td>
                                    <td>${(CustomerCar.carKind)?default('')}</td>
                                    <td>${(CustomerCar.brand)?default('')}</td>
                                    <td>${(CustomerCar.useKind)?default('')}</td>
                                    <td>${((CustomerCar.regDate)?string('yyyy-MM-dd'))?default('')}</td>
                                    <td><span id="spCar_${CustomerCar.sn}"></span> 
                                    <script>
                                    [#list CustomerCar.ufList?default([]) as cid]
									$('#spCar_${CustomerCar.sn}').html($('#spCar_${CustomerCar.sn}').html()+getFileLink('${cid.sn}'));
                                [/#list]
								</script>
                                【<a href="javaScript:uploadFile('spCar_${CustomerCar.sn}','车辆','${CustomerCar.sn?default('')}','行车证');">上传</a>】</p></td>
                                </tr>
                                [/#list]
                                
                            </table>
                            
                        </div>
                        <div id="customer_driver">
                        	<input type="button" value="添加驾驶员" onClick="editDriver();">
                            <table width="100%" border="0" cellspacing="3" cellpadding="3">
                                <tr>
                                    <td bgcolor="#CCCCCC"><strong>证号</strong></td>
                                    <td bgcolor="#CCCCCC"><strong>姓名</strong></td>
                                    <td bgcolor="#CCCCCC"><strong>性别</strong></td>
                                    <td bgcolor="#CCCCCC"><strong>有效起始日期/期限</strong></td>
                                    <td bgcolor="#CCCCCC"><strong>驾驶证</strong></td>

                                </tr>
                                [#list obj.CustomerDriverList?default([]) as CustomerDriver]
                                <tr>
                                    <td><a href="javaScript:editDriver('${CustomerDriver.sn}');">${(CustomerDriver.cardNo)?default('空')}</a></td>
                                    <td>${(CustomerDriver.name)?default('')}</td>
                                    <td>${(CustomerDriver.sex)?default('')}</td>
                                    <td>${((CustomerDriver.validBeginDate)?string('yyyy-MM-dd'))?default('')}/${((CustomerDriver.validDate)?string('yyyy-MM-dd'))?default('')}</td>
                                    <td><span id="spDriver_${CustomerDriver.sn}"></span>
                                    <script> 
                                    [#list CustomerDriver.ufList?default([]) as cid]
									$('#spDriver_${CustomerDriver.sn}').html($('#spDriver_${CustomerDriver.sn}').html()+getFileLink('${cid.sn}'));
                                [/#list]
								</script>
                                【<a href="javaScript:uploadFile('spDriver_${CustomerDriver.sn}','驾驶员','${CustomerDriver.sn?default('')}','驾驶证');">上传</a>】</p></td>
                                </tr>
                                [/#list]
                                
                            </table>
                            
                        </div>
                    </div>
                    <div id="proxyInfo" style="width:830px">

                        <ul style="border-bottom:#aed0ea 1px solid;">
                            <li><a href="#proxy">经纪人</a></li>
                            <li><a href="#proxy_log">变更记录</a></li>

                        </ul>
                        <div id="proxy">
当前经纪人：admin<a href="#">变更经纪人</a></div>
                        <div id="proxy_log">
                            <table width="100%" border="0" cellspacing="1" cellpadding="0">
                                <tr>
                                    <td>原经纪人</td>
                                    <td>新经纪人</td>
                                    <td>变更时间</td>
                                </tr>
                                <tr>
                                    <td>test1</td>
                                    <td>admin</td>
                                    <td>2011-10-10</td>
                                </tr>
                                <tr>
                                    <td>test2</td>
                                    <td>test1</td>
                                    <td>2011-10-01</td>
                                </tr>
                            </table>

                        </div>

                    </div>
                </form>
                <script>
                  va = new Validation('mainForm');
                </script>
            </div>

        </div>
    </div>

[#include '../../bottom.ftl']
</div>
</body>
</html>